#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>

void childRun()
{
    int cnt = 5;
    while(cnt)
    {
        printf("I am child process!  %d\n", cnt--);
        sleep(1);
    }
    exit(171);
}


int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        childRun();
    }
    else
    {
        int status;
        pid_t forClild = waitpid(id, &status, 0);
        if(forClild != -1)
        {
            printf("wait sucess, retuen code: %d\n", WEXITSTATUS(status));
        }
        else
        {
            printf("wait fail");
        }
    }
    return 0;
}

